<template>
  <tl-sub-page :render="render" :visible.sync="visible" v-dialogDrag :title="title" :close-on-click-modal="false" class="tl-dialog" width="1200px" @open="open" @close="close">
    <el-form class="tl-form" ref="form" :model="model" :rules="rules" label-width="150px" :disabled="disableEditSubmit || disableSave">
      <el-row>
        <el-col :span="24">
          <el-divider content-position="left"><span>1、【项目基本信息变更】变更信息</span></el-divider>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="12">
          <el-form-item label="项目" prop="projectid" :rules="rulesProject">
            <el-input v-model="model.dispprojectid" :disabled="true" class="tl-ref-selector">
              <el-button slot="append" type="primary" icon="el-icon-search" @click="openpmProjectRefDialog" v-if="!disableEditSubmit"></el-button>
            </el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="24">
          <el-form-item label="变更原因" prop="changereason" :rules="rulesProject">
            <el-input v-model="model.changereason" type="textarea" :rows="2"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="12">
          <el-form-item label="项目名称(原)" prop="name">
            <el-input v-model="model.name" :disabled="true"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="项目名称(新)" prop="name2" :rules="rulesProject">
            <el-input v-model="model.name2"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="12">
          <el-form-item label="所属省份(原)" prop="province">
            <el-select v-model="model.province" filterable clearable :disabled="true">
              <el-option v-for="item in codeModel.provinceList" :key="item.code" :label="item.name" :value="item.code" />
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="所属省份(新)" prop="province2" :rules="rulesProject">
            <el-select v-model="model.province2" filterable clearable>
              <el-option v-for="item in codeModel.province2List" :key="item.code" :label="item.name" :value="item.code" />
            </el-select>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="12">
          <el-form-item label="客户名称(原)" prop="customercode">
            <el-input v-model="model.dispcustomercode" :disabled="true" class="tl-ref-selector">
              <el-button slot="append" type="primary" icon="el-icon-search" @click="openpmCustomerRefDialog" :disabled="true" v-if="!disableEditSubmit"></el-button>
            </el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="客户名称(新)" prop="customercode2" :rules="rulesProject">
            <el-input v-model="model.dispcustomercode2" :disabled="true" class="tl-ref-selector">
              <el-button slot="append" type="primary" icon="el-icon-search" @click="openpmCustomerRefDialog" v-if="!disableEditSubmit"></el-button>
            </el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <!-- <el-row>
        <el-col :span="12">
          <el-form-item label="客户编号(原)" prop="customercode">
            <el-input v-model="model.customercode"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="客户编号(新)" prop="customercode2">
            <el-input v-model="model.customercode2"></el-input>
          </el-form-item>
        </el-col>
      </el-row> -->
      <el-row>
        <el-col :span="24">
          <el-form-item label="项目目标(原)" prop="projecttarget">
            <el-input v-model="model.projecttarget" type="textarea" :rows="2" :disabled="true"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="24">
          <el-form-item label="项目目标(新)" prop="projecttarget2">
            <el-input v-model="model.projecttarget2" type="textarea" :rows="2"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="24">
          <el-form-item label="项目背景(原)" prop="background">
            <el-input v-model="model.background" type="textarea" :rows="2" :disabled="true"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="24">
          <el-form-item label="项目背景(新)" prop="background2">
            <el-input v-model="model.background2" type="textarea" :rows="2"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <!-- <el-row>
                <el-col :span="12">
                    <el-form-item label="项目级别(原)" prop="projectlevel">
                        <el-select v-model="model.projectlevel" filterable clearable :disabled="true">
                            <el-option v-for="item in codeModel.projectlevelList" :key="item.code" :label="item.name" :value="item.code" />
                        </el-select>
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item label="项目级别(新)" prop="projectlevel2">
                        <el-select v-model="model.projectlevel2" filterable clearable>
                            <el-option v-for="item in codeModel.projectlevel2List" :key="item.code" :label="item.name" :value="item.code" />
                        </el-select>
                    </el-form-item>
                </el-col>
            </el-row> -->
      <el-row>
        <el-col :span="12">
          <el-form-item label="所属公司名称(原)" prop="ownerorgname">
            <tl-ref-org v-model="model.ownerorgname" :initDisplayData.sync="model.ownerorgname" dataType="code" :singleSelect="true" :disabled="true"></tl-ref-org>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="所属公司名称(新)" prop="ownerorgname2" :rules="rulesProject">
            <tl-ref-org v-model="model.ownerorgname2" :initDisplayData.sync="model.ownerorgname2" dataType="code" :singleSelect="true" @confirm="ownerorgnameConfirm"></tl-ref-org>
          </el-form-item>
        </el-col>
      </el-row>
      <!-- <el-row>
        <el-col :span="12">
          <el-form-item label="所属公司编码(原)" prop="ownerorgcode">
            <el-input v-model="model.ownerorgcode"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="所属公司编码(新)" prop="ownerorgcode2">
            <el-input v-model="model.ownerorgcode2"></el-input>
          </el-form-item>
        </el-col>
      </el-row> -->
      <!-- <el-row>
        <el-col :span="12">
          <el-form-item label="所属部门编码(原)" prop="ownerdeptcode">
            <el-input v-model="model.ownerdeptcode"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="所属部门编码(新)" prop="ownerdeptcode2">
            <el-input v-model="model.ownerdeptcode2"></el-input>
          </el-form-item>
        </el-col>
      </el-row> -->
      <el-row>
        <el-col :span="12">
          <el-form-item label="所属部门名称(原)" prop="ownerdeptname">
            <tl-ref-dept v-model="model.ownerdeptname" :initDisplayData.sync="model.ownerdeptname" dataType="code" nameType="fullname" :singleSelect="true" :disabled="true" :externalQueryParam="{qry_enabled:1}"></tl-ref-dept>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="所属部门名称(新)" prop="ownerdeptname2" :rules="rulesProject">
            <tl-ref-dept v-model="model.ownerdeptname2" :initDisplayData.sync="model.ownerdeptname2" dataType="code" nameType="fullname" :singleSelect="true" @confirm="ownerdeptnameConfirm" :externalQueryParam="{qry_enabled:1}"></tl-ref-dept>
          </el-form-item>
        </el-col>

      </el-row>
      <el-row>
        <el-col :span="12">
          <el-form-item label="项目经理(原)" prop="projectmanagername">
            <tl-ref-user v-model="model.projectmanagername" :initDisplayData.sync="model.projectmanagername" dataType="code" :singleSelect="true" :disabled="true"></tl-ref-user>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="项目经理(新)" prop="projectmanagername2" :rules="rulesProject">
            <tl-ref-user v-model="model.projectmanagername2" :initDisplayData.sync="model.projectmanagername2" dataType="code" :singleSelect="true" @confirm="projectmanagernameConfirm"></tl-ref-user>
          </el-form-item>
        </el-col>
      </el-row>
      <!-- <el-row>
        <el-col :span="12">
          <el-form-item label="项目经理工号(原)" prop="projectmanagercode">
            <el-input v-model="model.projectmanagercode"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="项目经理工号(新)" prop="projectmanagercode2">
            <el-input v-model="model.projectmanagercode2"></el-input>
          </el-form-item>
        </el-col>
      </el-row> -->
      <el-row>
        <el-col :span="12">
          <el-form-item label="销售经理(原)" prop="areamanagername">
            <tl-ref-user v-model="model.areamanagername" :initDisplayData.sync="model.areamanagername" dataType="code" :singleSelect="true" :disabled="true"></tl-ref-user>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="销售经理(新)" prop="areamanagername2" :rules="rulesProject">
            <tl-ref-user v-model="model.areamanagername2" :initDisplayData.sync="model.areamanagername2" dataType="code" :singleSelect="true" @confirm="areamanagernameConfirm"></tl-ref-user>
          </el-form-item>
        </el-col>
      </el-row>
      <!-- <el-row>
        <el-col :span="12">
          <el-form-item label="销售经理工号(原)" prop="areamanagercode">
            <el-input v-model="model.areamanagercode"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="销售经理工号(新)" prop="areamanagercode2">
            <el-input v-model="model.areamanagercode2"></el-input>
          </el-form-item>
        </el-col>
      </el-row> -->
      <el-row>
        <el-col :span="24">
          <el-form-item label="承接原因(原)" prop="reason">
            <el-input v-model="model.reason" type="textarea" :rows="2" :disabled="true"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="24">
          <el-form-item label="承接原因(新)" prop="reason2">
            <el-input v-model="model.reason2" type="textarea" :rows="2"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="12">
          <el-form-item label="项目类别(原)" prop="category">
            <el-select v-model="model.category" filterable clearable :disabled="true">
              <el-option v-for="item in codeModel.categoryList" :key="item.code" :label="item.name" :value="item.code" />
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="项目类别(新)" prop="category2">
            <el-select v-model="model.category2" filterable clearable>
              <el-option v-for="item in codeModel.category2List" :key="item.code" :label="item.name" :value="item.code" />
            </el-select>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="24">
          <el-form-item label="项目概况(原)" prop="overview">
            <el-input v-model="model.overview" type="textarea" :rows="2" :disabled="true"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="24">
          <el-form-item label="项目概况(新)" prop="overview2">
            <el-input v-model="model.overview2" type="textarea" :rows="2"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="12">
          <el-form-item label="项目金额(原)" prop="projectmoney">
            <el-input-number v-model="model.projectmoney" controls-position="right" :step="1" :min="0" style="width:100%" :disabled="true"></el-input-number>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="项目金额(新)" prop="projectmoney2">
            <el-input-number v-model="model.projectmoney2" controls-position="right" :step="1" :min="0" style="width:100%"></el-input-number>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="12">
          <el-form-item label="计划开工时间(原)" prop="planstarttime">
            <el-date-picker v-model="model.planstarttime" type="date" placeholder="计划开工时间(原)" value-format="yyyy-MM-dd" :disabled="true"></el-date-picker>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="计划开工时间(新)" prop="planstarttime2">
            <el-date-picker v-model="model.planstarttime2" type="date" placeholder="计划开工时间(新)" value-format="yyyy-MM-dd"></el-date-picker>
          </el-form-item>
        </el-col>
      </el-row>
      <!-- <el-row>
        <el-col :span="12">
          <el-form-item label="计划完工时间(原)" prop="planendtime">
            <el-date-picker v-model="model.planendtime" type="date" placeholder="计划完工时间(原)" value-format="yyyy-MM-dd" :disabled="true"></el-date-picker>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="计划完工时间(新)" prop="planendtime2">
            <el-date-picker v-model="model.planendtime2" type="date" placeholder="计划完工时间(新)" value-format="yyyy-MM-dd"></el-date-picker>
          </el-form-item>
        </el-col>
      </el-row> -->
      <el-row>
        <el-col :span="12">
          <el-form-item label="是否含产品(原)" prop="isincludeproducts">
            <el-select v-model="model.isincludeproducts" filterable clearable :disabled="true" :value="model.isincludeproducts">
              <el-option v-for="item in codeModel.isincludeproductsList" :key="item.code" :label="item.name" :value="item.code" />
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="是否含产品(新)" prop="isincludeproducts2">
            <el-select v-model="model.isincludeproducts2" filterable clearable>
              <el-option v-for="item in codeModel.isincludeproducts2List" :key="item.code" :label="item.name" :value="item.code" />
            </el-select>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="24">
          <el-form-item label="产品明细(原)" prop="productdetails">
            <el-input v-model="model.productdetails" type="textarea" :rows="2" :disabled="true"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="24">
          <el-form-item label="产品明细(新)" prop="productdetails2">
            <el-input v-model="model.productdetails2" type="textarea" :rows="2"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="12">
          <el-form-item label="是否外包(原)" prop="ispurchase">
            <el-select v-model="model.ispurchase" filterable clearable>
              <el-option v-for="item in codeModel.ispurchaseList" :key="item.code" :label="item.name" :value="item.code" :disabled="true" />
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="是否外包(新)" prop="ispurchase2">
            <el-select v-model="model.ispurchase2" filterable clearable>
              <el-option v-for="item in codeModel.ispurchase2List" :key="item.code" :label="item.name" :value="item.code" />
            </el-select>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="24">
          <el-form-item label="外包说明(原)" prop="purchasedescription">
            <el-input v-model="model.purchasedescription" type="textarea" :rows="2" :disabled="true"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="24">
          <el-form-item label="外包说明(新)" prop="purchasedescription2">
            <el-input v-model="model.purchasedescription2" type="textarea" :rows="2"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="12">
          <el-form-item label="人天估算(原)" prop="mandays">
            <el-input-number v-model="model.mandays" controls-position="right" :step="1" :min="0" style="width:100%" :disabled="true"></el-input-number>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="人天估算(新)" prop="mandays2">
            <el-input-number v-model="model.mandays2" controls-position="right" :step="1" :min="0" style="width:100%"></el-input-number>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="24">
          <el-form-item label="备注" prop="description">
            <el-input v-model="model.description" type="textarea" :rows="2"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <!-- <el-row>
        <el-col :span="12">
          <el-form-item label="申请公司编码" prop="orgcode">
            <el-input v-model="model.orgcode"></el-input>
          </el-form-item>
        </el-col>
      </el-row> -->
      <el-collapse>
        <el-collapse-item title="【单据】相关信息">
          <el-row>
            <el-col :span="12">
              <el-form-item label="申请部门" prop="deptname">
                <tl-ref-dept v-model="model.deptcode" :initDisplayData.sync="model.deptname" :disabled="true" dataType="code" nameType="fullname" :singleSelect="true" :externalQueryParam="{qry_enabled:1}"></tl-ref-dept>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="申请公司" prop="orgname">
                <el-input v-model="model.orgname" :readonly="true" class="is-disabled"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <el-form-item label="申请人" prop="username">
                <tl-ref-user v-model="model.username" :initDisplayData.sync="model.username" :disabled="true" dataType="code" :singleSelect="true"></tl-ref-user>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="申请人工号" prop="usercode">
                <el-input v-model="model.usercode" :readonly="true" class="is-disabled"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <el-form-item label="单据日期" prop="docdate" :rules="rulesProject">
                <el-date-picker v-model="model.docdate" type="date" placeholder="单据日期" value-format="yyyy-MM-dd"></el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="提交时间" prop="submitdate">
                <el-date-picker v-model="model.submitdate" type="datetime" placeholder="提交时间" disabled></el-date-picker>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <el-form-item label="审批流程" prop="flowid">
                <el-input v-model="model.dispflowid" :readonly="true" class="is-disabled"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="状态" prop="state">
                <el-input v-model="model.dispstate" disabled></el-input>
              </el-form-item>
            </el-col>
          </el-row>
        </el-collapse-item>
      </el-collapse>
      <!-- <el-row>
        <el-col :span="12">
          <el-form-item label="排序码" prop="sortcode">
            <el-input-number v-model="model.sortcode" controls-position="right" :step="1" :min="0" style="width:100%"></el-input-number>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="有效" prop="enabled">
            <el-radio-group v-model="model.enabled">
              <el-radio :label="parseInt(item.code)" v-for="item in codeModel.enabledList" :key="item.code">{{ item.name }}</el-radio>
            </el-radio-group>
          </el-form-item>
        </el-col>
      </el-row> -->
    </el-form>
    <tl-approval-history ref="history" sourceType="PmProjectChange" :sourceId="model.id" />
    <div slot="footer" class="dialog-footer">
      <el-button :type="disableEditSubmit === false ? 'text' : 'primary'" @click="doCancelEdit">取消</el-button>
      <el-button type="primary" @click="doSubmitEdit" :loading="saveLoading" v-if="!disableEditSubmit" :disabled="disableSave">
        <svg-icon icon-class="save" />保存
      </el-button>
      <tl-attachment sourceType="PmProjectChange" :sourceId="model.id" :disabled="disableAttachmentButton" btnTitle="相关文件"></tl-attachment>
      <el-button type="primary" @click="doSubmitApproval" :loading="submitLoading" v-if="!disableEditSubmit" :disabled="disableApproval">
        <svg-icon icon-class="send" />提交审批
      </el-button>
      <el-button type="primary" @click="$refs.history.visible = true" :disabled="disableApprovalHistory">
        <svg-icon icon-class="list" />审批历史
      </el-button>
      <el-button type="primary" @click="doDelApproval" :loading="delApprovalLoading" v-if="!disableDelApproval" :disabled="disableDelApproval">
        <svg-icon icon-class="undo" />取消审批
      </el-button>
    </div>
    <tlpm-project-ref ref="pmProjectRef" @confirm="getpmProjectRefData" :isSingleSelect="true" :externalQueryParam="{ qry_changeFlag: '1' }"></tlpm-project-ref>
    <tlpm-customer-ref ref="pmCustomerRef" @confirm="getpmCustomerRefData" :isSingleSelect="true"></tlpm-customer-ref>
    <tlpm-customer-ref ref="pmCustomerRef" @confirm="getpmCustomerRefDataNew" :isSingleSelect="true"></tlpm-customer-ref>
  </tl-sub-page>
</template>

<script>
/** mixins */
import { mixin_approval_edit } from '@tapui/mixins/mixin_approval_edit'
import { mixin_validate } from '@/mixins/mixin_validate'
/** 子组件 */
import tlpmProjectRef from '@/views/ProjectManage/pmProject/refList.vue'
import tlpmCustomerRef from '@/views/ProjectManage/pmCustomer/refList.vue'
/** 工具类 */
import { putAction, getAction, postAction, deleteAction } from '@tapui/utils/http'
/** VUE配置 */
export default {
  mixins: [mixin_approval_edit, mixin_validate],
  components: { tlpmProjectRef, tlpmCustomerRef },
  data() {
    return {
      moduleTitle: '项目基本信息变更申请',
      urlPrefix: '/pm/projectChange/',
      disableAttachmentButton: true,
      url: {
        // 额外的url
      }
    }
  },
  methods: {
    assignDefaultValue() {
      if (this.isAdd) {
        // if (this.codeModel.flowidList && this.codeModel.flowidList.length > 0) {
        //   this.$set(this.model, 'flowid', parseInt(this.codeModel.flowidList[0].id))
        // }
        this.$set(this.model, 'applytime', new Date())
        // this.$set(this.model, 'orgcode', this.org.code)
        // this.$set(this.model, 'orgname', this.org.name)
        // this.$set(this.model, 'deptcode', this.dept.code)
        // this.$set(this.model, 'deptname', this.dept.fullname)
        this.$set(this.model, 'usercode', this.user.code)
        this.$set(this.model, 'username', this.user.name)
        this.$set(this.model, 'applytime', new Date())
        this.$set(this.model, 'docdate', new Date())
      }
    },
    afterDelApproval() {
      this.disableAttachmentButton = false
    },
    loaded() {
      if (this.isAdd === false && this.disableEditSubmit === true) {
        var params = {
          sourceType: 'PmProjectChange',
          sourceId: this.model.id
        }
        this.disableAttachmentButton = false
        getAction('/cbo/attachment/calculateCount', params).then((res) => {
          if (res.success) {
            if (res.result === 0) {
              this.disableAttachmentButton = true
              this.$emit('refresh')
            }
          }
        })
      }
      // 页面加载完毕执行
      if (!this.isAdd && this.model.docno) {
        this.title = this.title + `（单据编号：${this.model.docno}）`
      }
    },
    /** 执行新增提交 */
    doAdd() {
      this.saveLoading = true
      // 增加唯一单号
      this.$set(this.model, 'billuid', this.uid)
      postAction(this.url.add, this.model)
        .then(res => {
          if (res.success) {
            this.$tap.message('添加成功', 'success')
            this.queryData(res.result.id)
            this.disableAttachmentButton = false
            this.isAdd = false
          } else {
            this.$tap.alert(res.message, 'warning')
          }
          this.afterSubmit()
          this.saveLoading = false
        })
        .catch(err => {
          this.saveLoading = false
        })
    },
    /** 打开项目参照 */
    openpmProjectRefDialog() {
      this.$refs.pmProjectRef.visible = true
    },
    /** 获取项目参数数据 */
    getpmProjectRefData(selectionRow, selectKey, selectionValue) {
      this.$set(this.model, 'projectid', selectionRow.id)
      this.$set(this.model, 'dispprojectid', selectionRow.name)
      this.$set(this.model, 'customername', selectionRow.dispcustomercode)
      this.$set(this.model, 'customercode', selectionRow.customercode)
      this.$set(this.model, 'dispcustomercode', selectionRow.dispcustomercode)
      this.$set(this.model, 'name', selectionRow.name)
      this.$set(this.model, 'projecttarget', selectionRow.projecttarget)
      this.$set(this.model, 'background', selectionRow.background)
      this.$set(this.model, 'projectlevel', selectionRow.projectlevel)
      this.$set(this.model, 'ownerorgname', selectionRow.ownerorgname)
      this.$set(this.model, 'ownerorgcode', selectionRow.ownerorgcode)
      this.$set(this.model, 'ownerdeptname', selectionRow.ownerdeptname)
      this.$set(this.model, 'ownerdeptcode', selectionRow.ownerdeptcode)
      this.$set(this.model, 'province', selectionRow.province)
      this.$set(this.model, 'province2', selectionRow.province)

      this.$set(this.model, 'projectmanagername', selectionRow.projectmanagername)
      this.$set(this.model, 'projectmanagercode', selectionRow.projectmanagercode)
      this.$set(this.model, 'areamanagername', selectionRow.areamanagername)
      this.$set(this.model, 'areamanagercode', selectionRow.areamanagercode)
      this.$set(this.model, 'reason', selectionRow.reason)
      this.$set(this.model, 'category', selectionRow.category)
      this.$set(this.model, 'overview', selectionRow.overview)
      this.$set(this.model, 'projectmoney', selectionRow.projectmoney)
      this.$set(this.model, 'planstarttime', selectionRow.planstarttime)

      this.$set(this.model, 'planendtime', selectionRow.planendtime)
      this.$set(this.model, 'isincludeproducts', selectionRow.isincludeproducts)
      this.$set(this.model, 'productdetails', selectionRow.productdetails)
      this.$set(this.model, 'ispurchase', selectionRow.ispurchase)
      this.$set(this.model, 'purchasedescription', selectionRow.purchasedescription)
      this.$set(this.model, 'mandays', selectionRow.mandays)

      this.$set(this.model, 'customername2', selectionRow.dispcustomercode)
      this.$set(this.model, 'customercode2', selectionRow.customercode)
      this.$set(this.model, 'dispcustomercode2', selectionRow.dispcustomercode)
      this.$set(this.model, 'name2', selectionRow.name)
      this.$set(this.model, 'projecttarget2', selectionRow.projecttarget)
      this.$set(this.model, 'background2', selectionRow.background)
      this.$set(this.model, 'projectlevel2', selectionRow.projectlevel)
      this.$set(this.model, 'ownerorgname2', selectionRow.ownerorgname)
      this.$set(this.model, 'ownerorgcode2', selectionRow.ownerorgcode)
      this.$set(this.model, 'ownerdeptname2', selectionRow.ownerdeptname)
      this.$set(this.model, 'ownerdeptcode2', selectionRow.ownerdeptcode)

      this.$set(this.model, 'projectmanagername2', selectionRow.projectmanagername)
      this.$set(this.model, 'projectmanagercode2', selectionRow.projectmanagercode)
      this.$set(this.model, 'areamanagername2', selectionRow.areamanagername)
      this.$set(this.model, 'areamanagercode2', selectionRow.areamanagercode)
      this.$set(this.model, 'reason2', selectionRow.reason)
      this.$set(this.model, 'category2', selectionRow.category)
      this.$set(this.model, 'overview2', selectionRow.overview)
      this.$set(this.model, 'projectmoney2', selectionRow.projectmoney)
      this.$set(this.model, 'planstarttime2', selectionRow.planstarttime)

      this.$set(this.model, 'planendtime2', selectionRow.planendtime)
      this.$set(this.model, 'isincludeproducts2', selectionRow.isincludeproducts)
      this.$set(this.model, 'productdetails2', selectionRow.productdetails)
      this.$set(this.model, 'ispurchase2', selectionRow.ispurchase)
      this.$set(this.model, 'purchasedescription2', selectionRow.purchasedescription)
      this.$set(this.model, 'mandays2', selectionRow.mandays)
      // this.$set(this.model, 'planstarttime', selectionRow.planstarttime)
      // this.$set(this.model, 'planstarttime', selectionRow.planstarttime)
      // this.$set(this.model, 'planstarttime', selectionRow.planstarttime)
      // this.$set(this.model, 'planstarttime', selectionRow.planstarttime)
      // this.$set(this.model, 'planstarttime', selectionRow.planstarttime)
      // this.$set(this.model, 'planstarttime', selectionRow.planstarttime)
      // this.$set(this.model, 'planstarttime', selectionRow.planstarttime)
      // this.$set(this.model, 'planstarttime', selectionRow.planstarttime)
      // this.$set(this.model, 'planstarttime', selectionRow.planstarttime)
      // this.$set(this.model, 'planstarttime', selectionRow.planstarttime)
      // this.$set(this.model, 'planstarttime', selectionRow.planstarttime)
      // this.$set(this.model, 'planstarttime', selectionRow.planstarttime)
      // this.model = selectionRow
      this.$set(this.model, 'deptcode', selectionRow.ownerdeptcode)
      this.$set(this.model, 'deptname', selectionRow.ownerdeptname)
      this.$set(this.model, 'orgcode', selectionRow.ownerorgcode)
      this.$set(this.model, 'orgname', selectionRow.ownerorgname)
    },
    /** 打开客户名称(原)参照 */
    openpmCustomerRefDialog() {
      this.$refs.pmCustomerRef.visible = true
    },
    /** 获取客户名称(原)参数数据 */
    getpmCustomerRefData(selectionRow, selectKey, selectionValue) {
      this.$set(this.model, 'customername', selectionRow.id)
    },
    /** 打开客户名称(新)参照 */
    openpmCustomerRefDialogNew() {
      this.$refs.pmCustomerRef.visible = true
    },
    /** 获取客户名称(新)参数数据 */
    getpmCustomerRefDataNew(selectionRow, selectKey, selectionValue) {
      this.$set(this.model, 'dispcustomercode2', selectionRow.name)
      this.$set(this.model, 'customercode2', selectionRow.id)
    },
    // 所属公司点击确认
    ownerorgnameConfirm(selectionRow) {
      this.$set(this.model, 'ownerorgcode2', selectionRow[0].code)
      this.$set(this.model, 'ownerorgname2', selectionRow[0].name)
    },
    // 所属部门点击确认
    ownerdeptnameConfirm(selectionRow) {
      this.$set(this.model, 'ownerdeptcode2', selectionRow[0].code)
      this.$set(this.model, 'ownerdeptname2', selectionRow[0].name)
    },
    // 项目经理点击确认
    projectmanagernameConfirm(selectionRow) {
      this.$set(this.model, 'projectmanagercode2', selectionRow[0].code)
      this.$set(this.model, 'projectmanagername2', selectionRow[0].name)
    },
    // 销售经理点击取确认
    areamanagernameConfirm(selectionRow) {
      this.$set(this.model, 'areamanagercode2', selectionRow[0].code)
      this.$set(this.model, 'areamanagername2', selectionRow[0].name)
    }
  }
}
</script>

